package com.yanqu.road.server.manger.activity.chefduel;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.chefduel.ChefDuelProto;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class OtherActivityChefDuelActivityMgr extends TempMgr {

    private static Map<Integer, OtherActivityChefDuel2> chefDuel2Map = new ConcurrentHashMap<>();//活动map

    public static void syncActivityInfo(ActivityInfo activityInfo) {
        OtherActivityChefDuel2 cookBoy2 = chefDuel2Map.get(activityInfo.getActivityId());
        if(cookBoy2 == null){
            cookBoy2 = new OtherActivityChefDuel2(activityInfo);
            chefDuel2Map.put(activityInfo.getActivityId(), cookBoy2);
        }else {
            cookBoy2.setActivityInfo(activityInfo);
        }
        getLogger().debug("同步厨神对决二阶段赴宴范围的活动信息{}，crossId {}", activityInfo.getActivityId(), activityInfo.getCrossId());
        GamePlayerMgr.sendPacket(0, YanQuMessageUtils.buildMessage(Protocol.C_CROSS_CHEF_DUEL2_SYNC_ACTIVITY_BACK,
                ChefDuelProto.CrossChefDuel2ActivityInfoSyncBack.newBuilder().setActivityId(activityInfo.getActivityId())));
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static OtherActivityChefDuel2 getOtherActivityChefDuel2(int activityId){
        return chefDuel2Map.get(activityId);
    }

    public static Map<Integer, OtherActivityChefDuel2> getChefDuel2Map() {
        return chefDuel2Map;
    }
}
